******************************************************************************
******************************** Let’s party! ********************************
**** The impact of local festivities on the incumbent’s electoral support ****
******************************************************************************
************************ Guinjoan, Marc & Toni Rodon *************************
******************************************************************************
************************** Local Government Studies **************************
******************************************************************************

use Letsparty_db, clear

**********************************************************************************
******************************* MAIN MANUSCRIPT **********************************
**********************************************************************************

***Table 1: Support for the party of the Mayor in the 2015 elections

eststo clear

eststo: qreg diff_support change_festivities1113_14 festivities1113 logpopulation15  p_population_foreign i.region 
eststo: qreg diff_support change_festivities1113_14 festivities1113 logpopulation15 p_population_foreign change_turnout i.party_mayor  i.region 
eststo: qreg diff_support change_festivities1113_14 festivities1113 logpopulation15  p_population_foreign change_turnout i.party_mayor change_budget11_14 budgethab11 change_unemploy11_15 unemploy11 change_debt11_15 debt11 i.region
eststo: qreg diff_support change_festivities1113_14 festivities1113 logpopulation15  p_population_foreign change_turnout i.party_mayor change_budget11_14 budgethab11 change_unemploy11_15 unemploy11 change_debt11_15 debt11 logmarginvictory2011 i.region

esttab using Table1.html, title("Table 1: Support for the party of the Mayor in the 2015 elections") b(3) se(3) label mtitles ("M1" "M2" "M3" "M4") drop(1.party_mayor) refcat(2.party_mayor "Political party: PP" , label("[Ref.]")) nonum coeflabels(_cons "Constant" ) nogaps indicate(Region FE=*region) starlevels(+ 0.1 * 0.05 ** 0.01 *** 0.001)  replace

***Figure 1. Histogram of the change in support for the mayor’s party in 2015, by political party
quiet reg diff_support change_festivities1113_14 festivities1113  logpopulation15 p_population_foreign i.region
hist diff_support if e(sample), plot(kdensity diff_support if (party_mayor==1) || kdensity diff_support if (party_mayor==2) || kdensity diff_support if (party_mayor==3) || kdensity diff_support if (party_mayor==4)) ytitle( , height(5)) xtitle("Change in support for the Mayor's party, 2011-2015", height(4)) legend(col(3) label(1 "All") label(2 "PP") label(3 "PSOE") label(4 "IU") label(5 "CiU") position(6) height(8)) xlabel(-60 (10) 50) graphregion(color(white)) color(gs10) fintensity(inten60) name(Figure1, replace)

***Figure 2. Predicted impact of the percentage change in the per capita amount of money allocated to local festivities between 2011-13 and 2014, on change in support for the Mayor’s party in 2015
qreg diff_support change_festivities1113_14 festivities1113 logpopulation15  p_population_foreign change_turnout i.party_mayor change_budget11_14 budgethab11 change_unemploy11_15 unemploy11 change_debt11_15 debt11 i.region
margins, at(change_festivities1113_14=(-1(0.1)1))
marginsplot, title("") xtitle("% change of per capita amount of money spent on festivities", size(medsmall) height(6)) xlabel(-1(0.2)1) ytitle("Change in support for the Mayor's party", size(medsmall))  name(Figure2, replace) graphregion(color(white))  addplot(histogram change_festivities1113_14, xlabel(-1 (0.2) 1) color(gs2%30) yaxis(2) yscale(alt axis(2)) below  width(0.05) legend(off))

***Figure 3. Marginal effect of the percentage change in the per capita amount of money allocated to festivities between 2011-13 and 2014 on the differences in support for the mayor’s party in 2015, across different moderators
eststo clear

*1. Bread and circus
qreg diff_support c.change_festivities1113_14##i.bullevents festivities1113  logpopulation15 p_population_foreign change_turnout i.party_mayor  change_budget11_14 budgethab11 change_unemploy11_15 unemploy11 change_debt11_15 debt11 i.region 
margins, dydx(change_festivities1113_14) at(bullevents=(0 1))
marginsplot, title("Bull festivities", size(medlarge)) xtitle("bull festivities", size(medsmall) height(6)) ytitle("Marginal effect of the % change of per""capita money on festivities 2013-14", size(medsmall) height(8)) yline(0)  xtitle(, height(6)) addplot(hist bullevents if e(sample), width(0.2) yaxis(2) percent yscale(alt axis(2)) ytitle("", axis(2)) ylabel("", axis(2)) xlabel(0 `""No bull" "events""' 1 `""Bull" "events""') xtitle("Bull events during the festivities") legend(off) color(%20))  graphregion(color(white)) name(int_bulls, replace) 
gr_edit .gmetric_mult = 0.7

*2.1 Satisfaction: Percentage debt
qreg diff_support c.change_festivities1113_14##c.debt15 festivities1113 logpopulation15 p_population_foreign change_turnout i.party_mayor  change_budget11_14 budgethab11 change_unemploy11_15 unemploy11 i.region   
margins, dydx(change_festivities1113_14) at(debt15=(0(1)24))
marginsplot, title("Public debt", size(medlarge)) xtitle("Percentage budget debt in 2015", size(medsmall) ) ytitle("Marginal effect of the % change of per""capita money on festivities 2013-14", size(medsmall) height(8)) yline(0) xtitle(, height(6)) addplot(hist debt15 if e(sample) & debt15<24, xlabel(0 (2) 24) width(0.5) yaxis(2) percent yscale(alt axis(2)) ytitle("", axis(2)) ylabel("", axis(2)) legend(off) color(%20)) graphregion(color(white)) name(int_debt, replace)
gr_edit .gmetric_mult = 0.7

*2.2 Satisfaction: Previous spending
qreg diff_support c.change_festivities1113_14##c.festivities1113  logpopulation15 change_turnout i.party_mayor change_budget11_14 budgethab11 change_unemploy11_15 unemploy11 change_debt11_15 debt11 p_population_foreign i.region
margins, dydx(change_festivities1113_14) at(festivities1113 =(0(40)200))
marginsplot, title("Budget in festivities per inhabitant 2011-2013", size(medlarge)) xtitle("Mean % budget 2011-13", size(medsmall) ) ytitle("Marginal effect of the % change of per""capita money on festivities 2013-14", size(medsmall) height(8)) yline(0) xtitle("Budget in festivities per inhabitant (in €) between 2011 and 2013", height(6)) addplot(hist festivities1113 if e(sample) & festivities1113<200, xlabel(0 (40) 200) width(20) yaxis(2) percent yscale(alt axis(2)) ytitle("", axis(2)) ylabel("", axis(2)) legend(off) color(%20)) graphregion(color(white)) name(int_prevspending, replace) 
gr_edit .gmetric_mult = 0.7
graph close int_bulls int_debt int_prevspending

graph combine int_bulls int_debt int_prevspending, graphregion(color(white)) name(Figure3, replace)



**********************************************************************************
**************************** SUPPORTING INFORMATION ******************************
**********************************************************************************

***Table S1b: Summary statistics
quiet qreg diff_support change_festivities1113_14 festivities1113  logpopulation15 p_population_foreign i.region
sum diff_support change_festivities1113_14 festivities1113 logpopulation15  p_population_foreign change_turnout i.party_mayor change_budget11_14 budgethab11 change_unemploy11_15 unemploy11 change_debt11_15 debt11 logmarginvictory2011 bullevents debt15 if e(sample)

***Figure S1a: Percentage change in the per capita amount of money allocated to local festivities between 2011-13 and 2014
hist change_festivities1113_14 if e(sample), graphregion(color(white)) width(0.05) xtitle("Percentage change of per capita amount of money spent on festivities") color(gs10) fintensity(inten60) name(FigureS1a, replace)

***Figure S2a. Evolution of the average per capita amount of money allocated to local festivities, 2011-2014
preserve
qreg diff_support change_festivities1113_14 festivities1113 logpopulation15  p_population_foreign change_turnout i.party_mayor change_budget11_14 budgethab11 change_unemploy11_15 unemploy11 change_debt11_15 debt11 logmarginvictory2011 i.region
keep if e(sample)
reshape long festivitiesinh , i(code_INE) j(year)
label values year .
qreg festivitiesinh i.year logpopulation15  p_population_foreign change_turnout i.party_mayor change_budget11_14 budgethab11 change_unemploy11_15 unemploy11 change_debt11_15 debt11 logmarginvictory2011 i.region
margins, at(year=(11 12 13 14))
marginsplot, title("") xlabel(11 "2011" 12 "2012" 13 "2013" 14 "2014") xtitle(Year, height(6)) ytitle(Mean per capita money allocated to festivities, height(6)) graphregion(color(white)) name(FigureS2a, replace) scale(0.8)
restore

***Figure S2b. The correlates of municipalities included in the sample
quiet reg diff_support change_festivities1113_14 festivities1113 logpopulation15  p_population_foreign i.region
gen esample=0
replace esample=1 if e(sample)
keep if diff_support!=.

foreach var of varlist diff_support logpopulation15 p_population_foreign change_turnout budgethab14 unemploy15 debt14 logmarginvictory2011 {
qui summ `var'
gen `var'_01 = (`var' - r(min)) / (r(max) - r(min))
} 

label var diff_support_01 "Dif. Mayor party"
label var p_population_foreign_01 "Foreign population"
label var change_turnout_01 "Change in turnout"
label var budgethab14_01 "Budget (2014)"
label var unemploy15_01 "Unemployment (2015)"
label var debt14_01 "Local debt (2014)" 
label var logmarginvictory2011_01 "(log) Margin of victory in 2011"

logit esample diff_support_01 logpopulation15_01 p_population_foreign_01 change_turnout_01 budgethab14_01 unemploy15_01 debt14_01 logmarginvictory2011_01 i.party_mayor i.region 

coefplot, base sch(plottig) drop (_cons ) coeflabels(logpopulation15_01= "(log) Population (2015)" 1.party_mayor = "Mayor: PP" 2.party_mayor = "Mayor: PSOE" 3.party_mayor = "Mayor: IU" 4.party_mayor = "Mayor: CiU" 5.party_mayor = "Mayor: Others" ) labels headings(1.party_mayor="{bf:Party Mayor}" 1.region="{bf:Region}" , labcolor(orange)) xline(0, lcolor(dkorange) lp(shortdash)) legend(off)  name(FigureS2b, replace)

***Table S3a: Robustness checks of the support for the party of the Mayor in the 2015 elections
eststo clear

eststo: rreg diff_support change_festivities1113_14 festivities1113 logpopulation15  p_population_foreign i.region
eststo: rreg diff_support change_festivities1113_14 festivities1113 logpopulation15 p_population_foreign change_turnout i.party_mayor  i.region
eststo: rreg diff_support change_festivities1113_14 festivities1113  logpopulation15  p_population_foreign change_turnout i.party_mayor change_budget11_14 budgethab11 change_unemploy11_15 unemploy11 change_debt11_15 debt11 i.region
eststo: rreg diff_support change_festivities1113_14 festivities1113 logpopulation15  p_population_foreign change_turnout i.party_mayor change_budget11_14 budgethab11 change_unemploy11_15 unemploy11 change_debt11_15 debt11 logmarginvictory2011 i.region 

esttab using TableS3a.html, title("Table S3a: Robustness checks of the support for the party of the Mayor in the 2015 elections") b(3) se(3) label mtitles ("M1" "M2" "M3" "M4") drop(1.party_mayor) refcat(2.party_mayor "Political party: PP" , label("[Ref.]")) nonum coeflabels(_cons "Constant" ) nogaps indicate(Region FE=*region) starlevels(+ 0.1 * 0.05 ** 0.01 *** 0.001)  replace

***Table S3b: Heterogeneous effects of the support for the party of the Mayor 2011-15 in 2015
eststo clear 

eststo: qreg diff_support c.change_festivities1113_14##i.bullevents festivities1113  logpopulation15 p_population_foreign change_turnout i.party_mayor  change_budget11_14 budgethab11 change_unemploy11_15 unemploy11 change_debt11_15 debt11 i.region  // Bread and circus hypothesis 
eststo: qreg diff_support c.change_festivities1113_14##c.debt15 festivities1113 logpopulation15 p_population_foreign change_turnout i.party_mayor  change_budget11_14 budgethab11 change_unemploy11_15 unemploy11 i.region // Satisfaction  hypothesis (1) 
eststo: qreg diff_support c.change_festivities1113_14##c.festivities1113  logpopulation15 change_turnout i.party_mayor change_budget11_14 budgethab11 change_unemploy11_15 unemploy11 change_debt11_15 debt11 p_population_foreign i.region // Satisfaction  hypothesis (2)

esttab using TableS3b.html, title("Table S3b: Heterogeneous effects of the support for the party of the Mayor 2011-15 in 2015") b(3) se(3) label mtitles ("M1" "M2" "M3") drop(1.party_mayor 0.bullevents ) refcat(2.party_mayor "Political party: PP" , label("[Ref.]")) nonum coeflabels(_cons "Constant" ) nogaps indicate(Region FE=*region) starlevels(+ 0.1 * 0.05 ** 0.01 *** 0.001)  replace

***Table S3c: Heterogeneous effects of the support for the party of the Mayor 2011-15 in 2015
eststo clear 

eststo: rreg diff_support c.change_festivities1113_14##i.bullevents festivities1113  logpopulation15 p_population_foreign change_turnout i.party_mayor  change_budget11_14 budgethab11 change_unemploy11_15 unemploy11 change_debt11_15 debt11 i.region  // Bread and circus hypothesis 
eststo: rreg diff_support c.change_festivities1113_14##c.debt15 festivities1113 logpopulation15 p_population_foreign change_turnout i.party_mayor  change_budget11_14 budgethab11 change_unemploy11_15 unemploy11 i.region // Satisfaction  hypothesis (1) 
eststo: rreg diff_support c.change_festivities1113_14##c.festivities1113  logpopulation15 change_turnout i.party_mayor change_budget11_14 budgethab11 change_unemploy11_15 unemploy11 change_debt11_15 debt11 p_population_foreign i.region // Satisfaction  hypothesis (2)

esttab using TableS3c.html, title("Table S3c: Heterogeneous effects of the support for the party of the Mayor 2011-15 in 2015 (robust OLS regression)") b(3) se(3) label mtitles ("M1" "M2" "M3") drop(1.party_mayor 0.bullevents ) refcat(2.party_mayor "Political party: PP" , label("[Ref.]")) nonum coeflabels(_cons "Constant" ) nogaps indicate(Region FE=*region) starlevels(+ 0.1 * 0.05 ** 0.01 *** 0.001)  replace

***Table S3d: Support for the party of the Mayor 2011-15 in the 2015 elections
eststo clear
eststo m3: qreg diff_support change_festivities1113_14 logpopulation15  p_population_foreign change_turnout i.party_mayor change_budget11_14 budgethab11 change_unemploy11_15 unemploy11 change_debt11_15 debt11 i.region
*population equal
preserve 
drop if population15>64400 & esample==1
ttest population15, by(esample)
eststo m3population: qreg diff_support change_festivities1113_14 logpopulation15  p_population_foreign change_turnout i.party_mayor change_budget11_14 budgethab11 change_unemploy11_15 unemploy11 change_debt11_15 debt11 i.region
restore
*logpopulation equal
preserve 
drop if logpopulation15>8.503 & esample==1
ttest logpopulation15, by(esample)
eststo m3logpopulation: qreg diff_support change_festivities1113_14 logpopulation15  p_population_foreign change_turnout i.party_mayor change_budget11_14 budgethab11 change_unemploy11_15 unemploy11 change_debt11_15 debt11 i.region
restore

esttab using TableS3d.html, title("Table S3d: Support for the party of the Mayor 2011-15 in the 2015 elections") b(3) se(3) label mtitles ("M1" "M2" "M3") drop(1.party_mayor) refcat(2.party_mayor "Political party: PP" , label("[Ref.]")) nonum coeflabels(_cons "Constant" ) nogaps indicate(Region FE=*region) starlevels(+ 0.1 * 0.05 ** 0.01 *** 0.001)  replace

******************************** END OF DO-FILE *******************************